﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NGinnBPM.Lib.Data;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Collections;
using NGinnBPM.Lib.Messages;

namespace NGinnBPM.Runtime.Messages
{
    /// <summary>
    /// Send a http request
    /// </summary>
    [Serializable]
    [DataContract]
    public class SendHttpRequest : ICorrelatedMessage
    {
        public SendHttpRequest()
        {
            RequestEncoding = "UTF-8";
            Method = "GET";
        }
        /// <summary>
        /// Http method GET/POST/PUT/DELETE
        /// </summary>
        [DataMember]
        public string Method { get; set; }
        /// <summary>
        /// Request headers
        /// </summary>
        [DataMember]
        public Hashtable Headers { get; set; }
        /// <summary>
        /// Request URL
        /// </summary>
        [DataMember]
        public string Url { get; set; }
        /// <summary>
        /// In case of GET requests, RequestData is appended in query string. In case of POST/PUT it's sent in request body
        /// as form data.
        /// </summary>
        [DataMember]
        
        public Hashtable RequestData;
        /// <summary>
        /// Request body text for POST/PUT requests
        /// </summary>
        [DataMember]
        public string RequestBodyText { get; set; }
        /// <summary>
        /// Auth user
        /// </summary>
        [DataMember]
        public string User { get; set; }
        /// <summary>
        /// Auth password
        /// </summary>
        [DataMember]
        public string Passwd { get; set; }

        [DataMember]
        public string RequestEncoding { get; set; }

        /// <summary>
        /// Set to true to send binary request. Pass binary data
        /// in RequestBodyText, Base64-encoded.
        /// In this case, response will also return binary data.
        /// </summary>
        [DataMember]
        public bool GoBinary { get; set; }

        /// <summary>
        /// True if SOAP fault should be treated as a normal response from web service call
        /// and returned. If false, system will assume an error and retry the request.
        /// </summary>
        [DataMember]
        public bool SOAPFaultIsValid { get; set; }

        /// <summary>
        /// Specify a regular expression that will be matched against web service
        /// response in case of SOAP fault. If match is found response will be returned
        /// as an expected result. Otherwise system will assume an exception and retry the message.
        /// </summary>
        [DataMember]
        public string ExpectedFaultString { get; set; }

        #region ICorrelatedMessage Members

        [DataMember]
        public string CorrelationId { get; set; }
        
        #endregion
    }
}
